@model MVCWeekOne.Models.RouteDetailDto
@{
    ViewData["Title"] = "工艺路线详情";
}

<div class="layui-card">
    <div class="layui-card-header">
        <h2 style="margin: 0; color: #1E9FFF;">
            <i class="layui-icon layui-icon-engine" style="font-size: 24px; margin-right: 8px;"></i>
            工艺路线详情
        </h2>
        <div style="float: right;">
            <a href="@Url.Action("Index", "Route")" class="layui-btn layui-btn-primary">
                <i class="layui-icon layui-icon-return"></i> 返回列表
            </a>
        </div>
    </div>
    <div class="layui-card-body">
        @if (!string.IsNullOrEmpty(ViewBag.ErrorMessage?.ToString()))
        {
            <div class="layui-alert layui-alert-danger">
                <i class="layui-icon layui-icon-close"></i>
                @ViewBag.ErrorMessage
            </div>
        }
        else if (Model?.Route != null)
        {
            <!-- 基本信息 -->
            <div class="layui-card">
                <div class="layui-card-header">
                    <h3>基本信息</h3>
                </div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">路线编号:</label>
                                <div class="layui-input-block">
                                    <span style="line-height: 38px;">@Model.Route.RouteCode</span>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">路线名称:</label>
                                <div class="layui-input-block">
                                    <span style="line-height: 38px;">@Model.Route.RouteName</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">状态:</label>
                                <div class="layui-input-block">
                                    <span style="line-height: 38px;">
                                        @if (Model.Route.IsEnabled)
                                        {
                                            <span class="layui-badge layui-bg-green">启用</span>
                                        }
                                        else
                                        {
                                            <span class="layui-badge">禁用</span>
                                        }
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">创建时间:</label>
                                <div class="layui-input-block">
                                    <span style="line-height: 38px;">@Model.Route.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">创建人:</label>
                                <div class="layui-input-block">
                                    <span style="line-height: 38px;">@Model.Route.CreateUser</span>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">修改时间:</label>
                                <div class="layui-input-block">
                                    <span style="line-height: 38px;">@(Model.Route.UpdateTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "-")</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    @if (!string.IsNullOrEmpty(Model.Route.UpdateUser))
                    {
                        <div class="layui-row">
                            <div class="layui-col-md6">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">修改人:</label>
                                    <div class="layui-input-block">
                                        <span style="line-height: 38px;">@Model.Route.UpdateUser</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    }
                </div>
            </div>

            <!-- 工序列表 -->
            <div class="layui-card" style="margin-top: 15px;">
                <div class="layui-card-header">
                    <h3>工序列表 (@(Model.Processes?.Count ?? 0) 个工序)</h3>
                </div>
                <div class="layui-card-body">
                    <table class="layui-table" lay-even lay-skin="row">
                        <thead>
                            <tr>
                                <th style="width: 60px;">序号</th>
                                <th>工序名称</th>
                                <th>工序类型</th>
                                <th style="width: 80px;">顺序</th>
                                <th style="width: 120px;">标准时间(分钟)</th>
                                <th style="width: 150px;">创建时间</th>
                                <th style="width: 100px;">创建人</th>
                                <th style="width: 150px;">修改时间</th>
                                <th style="width: 100px;">修改人</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (Model.Processes != null && Model.Processes.Any())
                            {
                                @for (int i = 0; i < Model.Processes.Count; i++)
                                {
                                    var process = Model.Processes[i];
                                    <tr>
                                        <td>@(i + 1)</td>
                                        <td>@process.ProcessName</td>
                                        <td>@process.ProcessType</td>
                                        <td>@process.Sequence</td>
                                        <td>@process.StandardTime</td>
                                        <td>@process.CreateTime.ToString("yyyy-MM-dd HH:mm")</td>
                                        <td>@process.CreateUser</td>
                                        <td>@(process.UpdateTime?.ToString("yyyy-MM-dd HH:mm") ?? "-")</td>
                                        <td>@process.UpdateUser</td>
                                    </tr>
                                }
                            }
                            else
                            {
                                <tr>
                                    <td colspan="9" style="text-align: center; color: #666;">
                                        <i class="layui-icon layui-icon-face-cry" style="font-size: 48px; display: block; margin: 20px 0;"></i>
                                        该工艺路线暂无工序数据
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        }
        else
        {
            <div style="text-align: center; padding: 50px;">
                <i class="layui-icon layui-icon-face-cry" style="font-size: 64px; color: #ccc; display: block; margin-bottom: 20px;"></i>
                <p style="color: #666; font-size: 16px;">未找到工艺路线信息</p>
                <a href="@Url.Action("Index", "Route")" class="layui-btn">返回列表</a>
            </div>
        }
    </div>
</div> 